package com.ruoyi.wxserver;
class DoublyListNode {
    int val;
    DoublyListNode next, prev;
    DoublyListNode(int x) { val = x; }
}
public class Test01 {


    DoublyListNode createDoublyLinkedList(int[] arr) {
        if (arr == null || arr.length == 0) {
            return null;
        }
        DoublyListNode head = new DoublyListNode(arr[0]);
        DoublyListNode cur = head;
        // for 循环迭代创建双链表
        for (int i = 1; i < arr.length; i++) {
            DoublyListNode newNode = new DoublyListNode(arr[i]);
            cur.next = newNode;
            newNode.prev = cur;
            cur = cur.next;
        }
        return head;
    }

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10000000; j++) {

            }
        }
        long end = System.currentTimeMillis();
        System.out.println("消耗时间:" + (end - start));

//        int nums[] = {1,2,3,4,5};
//        Test01 test01 = new Test01();
//        test01.createDoublyLinkedList(nums);



        /**
         * 环形数组
         */
        // 长度为 5 的数组
//        int[] arr = new int[]{1, 2, 3, 4, 5};
//        int i = 0;
//        // 模拟环形数组，这个循环永远不会结束
//        while (i < arr.length) {
//            System.out.println(arr[i]);
//            i = (i + 1) % arr.length;
//        }



//        int nums[] = {1,3,4,0,12};
//        new Test01().zero(nums);
    }
   /* public void zero(int nums[]){
        int fast = 0;
        int slow = 0;

        while (fast < nums.length){
            if (nums[fast] != 0){
                int temp = nums[fast];
                nums[fast] = nums[slow];
                nums[slow] = temp;
                slow++;
            }
            fast++;
        }
        for (int num : nums) {
            System.out.println(num);
        }
    }*/
}
